using UnityEngine;

public class SPR_CopyRenderer : MonoBehaviour
{
	[Header("-- Variables --")]
	[SerializeField]
	private SpriteRenderer Renderer;

	[SerializeField]
	private SpriteRenderer Target;

	[Space(10f)]
	[SerializeField]
	private bool Enabled = true;

	[Space(10f)]
	[Header("-- Optional --")]
	[SerializeField]
	private SpriteMask RenderMask;

	[Header("-- Player Specific --")]
	[SerializeField]
	private bool TargetPlayer;

	private SpriteRenderer StoredSpriteRenderer;

	private void LateUpdate()
	{
		if (!Enabled)
		{
			return;
		}
		if (!TargetPlayer)
		{
			if ((Object)(object)Target != (Object)null)
			{
				if ((Object)(object)Renderer != (Object)null)
				{
					Renderer.sprite = Target.sprite;
				}
				if ((Object)(object)RenderMask != (Object)null)
				{
					RenderMask.sprite = Target.sprite;
				}
			}
		}
		else
		{
			if (!((Object)(object)PlayerManager.Instance != (Object)null))
			{
				return;
			}
			if ((Object)(object)StoredSpriteRenderer == (Object)null)
			{
				StoredSpriteRenderer = ((Component)PlayerManager.Instance._PAnimation).GetComponent<SpriteRenderer>();
				return;
			}
			Renderer.sprite = StoredSpriteRenderer.sprite;
			if ((Object)(object)RenderMask != (Object)null)
			{
				RenderMask.sprite = StoredSpriteRenderer.sprite;
			}
		}
	}
}
